import { reqGetGoodsInfoData } from '@/api/index'
const state = {
  goodsInfo: {},
}
const actions = {
  async getGoodsInfoData({ commit }, searchParams) {
    const result = await reqGetGoodsInfoData(searchParams)
    if (result.code === 200) {
      commit('SAVE_GOODS_INFO_DATA', result.data)
    } else {
      console.log(result.message)
    }
  },
}
const mutations = {
  SAVE_GOODS_INFO_DATA(state, goodsInfo) {
    state.goodsInfo = goodsInfo
  },
}
const getters = {
  attrsList(state) {
    return state.goodsInfo.attrsList
  },
  goodsList(state) {
    return state.goodsInfo.goodsList
  },
  trademarkList(state) {
    return state.goodsInfo.trademarkList
  },
}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters,
}
